package com.leoman.dao;

import com.leoman.entity.Circle;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Query;

/**
 * CircleDao
 * Created by 涂奕恒 on 2016/11/23 0023 下午 3:42.
 */
public interface CircleDao extends JpaRepository<Circle, Integer>, JpaSpecificationExecutor<Circle> {

    @Query("select a from Circle a where a.user.id = ?1 and a.isDraft = 1")
    Circle iFindDraftByUserId(Integer userId);

    @Query("select a from Circle a where a.isDraft = 0 and a.isTop = 1")
    Circle iFindOneWithTop();

    @Query("select a from Circle a where a.isAdmin = 1")
    Circle iFindOneWithAdmin();
}